<ui:composition template="/pages/templates/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">Enregistrement des numéros</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:panel id="toggleable" header="ENREGISTREMENT DES NUMEROS"
				toggleable="true" toggleSpeed="500" widgetVar="panel">
				<p:fieldset id="saisie" legend="Saisie des informations"
					toggleable="true" toggleSpeed="500">
					<h:panelGrid columns="3" cellpadding="10">
						<p:outputLabel for="numeroDate" value="Numéro" />
						<p:calendar id="numeroDate"
							value="#{numeroBean.currentNumero.numeroDate}" locale="fr"
							navigator="true" showButtonPanel="true" required="true"
							pattern="dd/MM/yyyy">
							<p:ajax update="numeroDateMsg" event="keyup" />
						</p:calendar>
						<p:message id="numeroDateMsg" for="numeroDate" display="icon" />
					</h:panelGrid>

					<p:separator />

					<p:commandButton value="Enrégistrer"
						binding="#{numeroBean.btnSave}" action="#{numeroBean.saveNumero}"
						icon="ui-icon-disk" update="@all">
						<p:confirm header="Confirmation"
							message="Voulez-vous enrégistrer ?" icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Modifier" binding="#{numeroBean.btnUpdate}"
						action="#{numeroBean.updateNumero}" icon="ui-icon-refresh"
						update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous modifier ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Supprimer"
						binding="#{numeroBean.btnDelete}"
						action="#{numeroBean.deleteNumero}" icon="ui-icon-trash"
						update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous supprimer ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Annuler" action="#{numeroBean.resetField}"
						icon="ui-icon-cancel" update=":form:saisie" />

					<p:confirmDialog global="true" showEffect="puff"
						hideEffect="explode">
						<p:commandButton value="Oui" type="button"
							styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
						<p:commandButton value="Non" type="button"
							styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					</p:confirmDialog>
				</p:fieldset>

				<p:dataTable id="table" var="numero" value="#{numeroBean.numeros}"
					selection="#{numeroBean.selectedNumero}" selectionMode="single"
					rowKey="#{numero.numeroId}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					paginator="true" rows="10" rowsPerPageTemplate="5,10,15"
					styleClass="table">
					<p:ajax event="rowSelect" listener="#{numeroBean.updateField}"
						update=":form:saisie" />
					<p:column headerText="Identifiants" styleClass="column">
						<h:outputText value="#{numero.numeroId}" />
					</p:column>

					<p:column headerText="Numéros" styleClass="column">
						<h:outputText value="#{numero.numeroDate}" >
						<f:convertDateTime pattern="dd-MM-yyyy"/>
						</h:outputText>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
